/*
-----------------------------------------------------------------------------
Filename:    Simulator.h
-----------------------------------------------------------------------------

*/
#ifndef __Simulator_h_
#define __Simulator_h_

#include "BaseEngine.h";
#include "Map.h";
#include "WaterEmitter.h"
#include "logwriter.h";
#include "PhysXWorld.h";
#include "WeatherSystem.h"
#include "SimulatorGui.h";
#include "AppSettings.h"
#include "SceneImporter.h";
#include <vector>;
#include "../res/resource.h"


class Simulator : public BaseEngine
{
public:
	Map* mMap;

    Simulator(void);
    virtual ~Simulator(void);

private:
	SimulatorGui *mGui;

	int nCameraSpeed;
	bool bSceneSetUp;
	bool bTerrainLoaded;
    Ogre::Vector3 mTerrainPos;
	bool bPredictionModuleConnected;

    //PhysX Engine Obiects
	bool PhysXDebug;
	NxOgre::World* mWorld;
	NxOgre::Scene* mScene;
	float mLastTimeStep;
	NxOgre::MeshManager* mMeshManager;
	NxOgre::Material* mDefaultMaterial;
	Critter::RenderSystem* mRenderSystem;

	NxOgre::SceneGeometry* terrain;
	PhysXWorld *mPhysXWorld;
	WeatherSystem *mWeatherSystem;

	SceneImporter mSceneImporter;

	void advancePhysX(const Ogre::FrameEvent& evt);
	void itemSelected(SelectMenu* menu);
	void buttonHit(Button* button);
	void correctPosition(void);

	void writeBenchMarkResults(Ogre::String fileName);

protected:
    virtual bool keyPressed( const OIS::KeyEvent &arg );
	virtual bool mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id );
	virtual bool mouseMoved( const OIS::MouseEvent &arg );
	bool connectToPredictionModule(void);
	Ogre::String getSceneDescriptionFromPredictionModule(void);
	void getUpdateFromPredictionModule(void);
	void processUpdate(Ogre::String data);
    virtual void createScene(void);
	virtual void buildWorld(Ogre::String saveFileName);
	virtual void setupPhysics(void);
	virtual void resetPhysics(void);
	virtual bool frameRenderingQueued(const Ogre::FrameEvent& evt);
	virtual void createFrameListener(void);
	virtual void loadResources(void);
};

#endif // #ifndef __Simulator_h_
